import request from './request'

/**
 * 上传文档
 * @param {FormData} formData - 包含文件的FormData对象
 * @returns {Promise}
 */
export const uploadDocument = (formData) => {
  return request.post('/documents/upload', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 获取文档列表
 * @param {number} page - 页码
 * @param {number} size - 每页数量
 * @returns {Promise}
 */
export const getDocuments = (page, size) => {
  return request.get('/documents/list', {
    params: { page, size }
  })
}

/**
 * 删除文档
 * @param {number} documentId - 文档ID
 * @returns {Promise}
 */
export const deleteDocument = (documentId) => {
  return request.delete(`/documents/${documentId}`)
}

/**
 * 获取文档版本列表
 * @param {number} documentId - 文档ID
 * @returns {Promise}
 */
export const getVersions = (documentId) => {
  return request.get(`/documents/${documentId}/versions`)
}

/**
 * 对比文档版本
 * @param {number} version1Id - 版本1 ID
 * @param {number} version2Id - 版本2 ID
 * @returns {Promise}
 */
export const compareVersions = (version1Id, version2Id) => {
  return request.get('/documents/compare', {
    params: { version1Id, version2Id }
  })
}
